Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

[terra-arrange][terra-section-header] update to utilize semantic html elements #3831

Merged
merged 31 commits into from
Aug 1, 2023

Conversation

KV106606Viswanath
Copy link
Contributor

Summary

Currently Toggle Section Header wraps a H2 with a button which might not be valid HTML. While the screen reader does read and interpret code correctly, the invalid code could fail for other browsers or assistive technologies. Added valid html to avoid these failures.

What was changed:
Updated HTML code div elements with button and span tags to make it valid html.

Why it was changed:
To avoid failures of invalid html on other browsers or assistive technologies.

This PR resolves:

UXPLATFORM-9093


Thank you for contributing to Terra.
@cerner/terra

Copy link
Contributor

@sdadn sdadn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may need to update jest snapshots as well.

@@ -2,6 +2,9 @@

## Unreleased

* Changed
* Updated div elements with span tag elements.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Updated div elements with span tag elements.
* Updated Arrange to use `span` elements instead of `div`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Comment on lines 9 to 10
* Added
* Added a function "ArrangeComponent" to use Arrange component.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHANGELOGs are for consumers so we don't have to add entries for internal implementation changes.

Suggested change
* Added
* Added a function "ArrangeComponent" to use Arrange component.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed these 2 lines.

Comment on lines 6 to 7
* Updated div element with span tag element.
* Updated div element with button tag element.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Updated div element with span tag element.
* Updated div element with button tag element.
* Updated SectionHeader to use `span` & `button` elements instead of `div`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@sdadn sdadn changed the title Adding valid html for toggle section header [terra-arrange][terra-section-header] update to utilize semantic html elements Jun 26, 2023
.fit-block {
.icon-wrapper {
display: inline-flex;
font-size: 8px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these style values provided by UX..??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, these are not provided by UX team. I have added them to match the existing look of UI. If required i will check with UX team.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we need UX review for the above style changes !!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got +1 from UX

</div>
<div {...fillProps} className={cx('fill', align || alignFill, fillProps.className)}>
</span>
<span {...fillProps} className={cx('fill', align || alignFill, fillProps.className || 'fill-block')}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<span {...fillProps} className={cx('fill', align || alignFill, fillProps.className || 'fill-block')}>
<span {...fillProps} className={cx('fill', align || alignFill, fillProps.className, 'fill-block')}>

why are using || here with fillProps.classname ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed that || operator as it's not required here.

@@ -37,3 +37,16 @@
align-self: flex-start;
}
}

.fit-block {
.icon-wrapper {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this class intended for terra-arrange ? there are no reference in Arrange component for class icon-wrapper !!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class has been added in section header component, i have moved these styles into section header module scss file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rebase with main so that this file is up to date?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment on lines 157 to 163
const ArrangeComponent = () => (
<Arrange
fitStart={onClick && accordionIcon}
fill={<span aria-hidden={(onClick !== undefined)} className={cx('title', 'title-block')}>{headerText}</span>}
className={cx('title-arrange')}
/>
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be a variable instead of a function.

Copy link
Contributor Author

@KV106606Viswanath KV106606Viswanath Jul 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this function and added Arrange component directly inside ArrangeWrapperTag as part of latest updates.

/>
);

const buttonAttributes = (onClick) ? { 'aria-expanded': isOpen, 'aria-label': headerText } : undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these still needed? Should aria-expanded': isOpen be set on the <button> and 'aria-label': headerText be set on the <span>?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized I misread this. I don't think we need the ternary anymore since we can set { 'aria-expanded': isOpen, 'aria-label': headerText } directly on the <button>.

@sycombs
Copy link
Contributor

sycombs commented Jul 7, 2023

Comment on lines 170 to 176
<button {...buttonAttributes} type="button" tabIndex="-1" className={cx('arrange-wrapper toggle-button')}>
<ArrangeComponent />
</button>
) : (
<span tabIndex="-1" className={cx('arrange-wrapper')}>
<ArrangeComponent />
</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of these seem very similar so instead of defining these twice, we can do something like:

const ArrangeWrapperTag = onClick ? "button" : "span" ;
const type = onClick ? "button" : null;
// ... and so on for the other attributes

<ArrangeWrapperTag  (attributes) >
  <ArrangeComponent />
</ArrangeWrapperTag

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Comment on lines 8 to 13
* Added
* Added realistic examples for `terra-arrange`.
* Added realistic examples for `terra-toggle-section-header`.

* Added
* Added email validation for `terra-form-field`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's combine the Added sections:

Suggested change
* Added
* Added realistic examples for `terra-arrange`.
* Added realistic examples for `terra-toggle-section-header`.
* Added
* Added email validation for `terra-form-field`.
* Added
* Added realistic examples for `terra-arrange`.
* Added realistic examples for `terra-toggle-section-header`.
* Added email validation for `terra-form-field`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@@ -40,7 +47,6 @@
* Added
* Added terra-scroll A11y tests.
* Added an example in terra-content-container without interactive elements.
* Added examples for terra-content-container with dark colors.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entry was now Added.

@@ -4,7 +4,7 @@
[![NPM version](https://badgen.net/npm/v/terra-toggle-section-header)](https://www.npmjs.org/package/terra-toggle-section-header)
[![Build Status](https://badgen.net/travis/cerner/terra-core)](https://travis-ci.com/cerner/terra-core)

Toggle section header component that transitions content in and out with a click.
Toggle section header component that transitions content in and out with a click. For accessibility best practices, it is recommended that consumers should always use only one h1 tag per page or view. The one h1 tag should be the page title. A section header should never be a heading level 1.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is already in the terra-toggle-section-header About doc, can we remove it from the README? Consumers don't generally refer to the README for component guidance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@github-actions github-actions bot temporarily deployed to preview-pr-3831 July 28, 2023 11:42 Destroyed
@saket2403 saket2403 merged commit aca35f6 into main Aug 1, 2023
21 checks passed
@saket2403 saket2403 deleted the KV106606-ToggleSectionHeader-9093 branch August 1, 2023 07:11
SG067724 pushed a commit that referenced this pull request Aug 8, 2023
… elements (#3831)

Co-authored-by: ST063655 <ST063655@cerner.net>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants